import JsonData from "../../Json.js";
let { brideName, groomName, sharePhoto, pictureBanner } = JsonData.invite;
Page({
  data: {
    pictureBanner: pictureBanner,
    //朋友圈展示信息
    circleData: JsonData.circleData,
    userInfo: ""
  },
  onLoad: function() {},
  onReady: function() {
    this.setData({
      userInfo: wx.getStorageSync('user')
    });
  },
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {},
  onShareAppMessage: function (e) {
    return "button" === e.from && console.log(e.target), {
      title: `${brideName}&${groomName}的结婚邀请函`,
      path: "pages/index/index",
      imageUrl: sharePhoto,
      success: function (res) {
        console.log("转发成功:" + JSON.stringify(res));
      },
      fail: function (err) {
        console.log("转发失败:" + JSON.stringify(err));
      }
    };
  },
  previewImg: function (e) {
    let { current, imgs } = e.currentTarget.dataset;
    wx.previewImage({
      current: current,
      urls: imgs
    });
  },
  //点赞
  clickThumb: function(e) {
    let _this = this;
    let { item } = e.currentTarget.dataset;
    item.isPraise = !item.isPraise;
    if (item.isPraise) {
      item.praise.push({ id: this.user_info.id, userName: this.user_info.userName });
    } else {
      let index = item.praise.findIndex(function (i) { return i.id == _this.user_info.id; });
      item.praise.splice(index, 1);
    }
  },
});